package com.zhouh.golden.security.social.qq.connect;

import com.zhouh.golden.security.social.qq.api.QQ;
import com.zhouh.golden.security.social.qq.api.QQUserInfo;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.ConnectionValues;
import org.springframework.social.connect.UserProfile;

public class QQAdapter implements ApiAdapter<QQ> {
    /**
     * @description: 校验QQ是否可联通 true不做校验
     * @date: 2019/6/14 23:39
     * @author:zhouheng
     */
    @Override
    public boolean test(QQ api) {
        return true;
    }

    /**
     * @description: 提供个性化用户信息
     * @date: 2019/6/14 23:38
     * @author:zhouheng
     */
    @Override
    public void setConnectionValues(QQ api, ConnectionValues values) {
        QQUserInfo qqUserInfo = api.getUserInfo();
        values.setDisplayName(qqUserInfo.getNickname());
        values.setImageUrl(qqUserInfo.getFigureurl_qq_2());
        values.setProfileUrl(null);
        values.setProviderUserId(qqUserInfo.getOpenId());
    }

    @Override
    public UserProfile fetchUserProfile(QQ api) {
        return null;
    }

    @Override
    public void updateStatus(QQ api, String message) {
        // do nothing
    }
}
